<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./template.xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml">

    <ui:define name="top">
        Search Results
    </ui:define>

    <ui:define name="left">
    </ui:define>



    <ui:define name="body">
        <h:form rendered="#{itemCTRL.browsing}" id="catList">
            <h:selectOneMenu id="category" value="#{categoryCTRL.category.id}">
                <f:selectItem itemLabel="" itemValue="-1"/>
                <c:forEach items="#{categoryCTRL.categoryList}" var="items">
                    <f:selectItem itemValue="#{items.id}" itemLabel="#{items.level}#{items.name}"/>
                </c:forEach>
            </h:selectOneMenu>
            <h:commandButton value="Select Category" action="#{itemCTRL.selectCategoryToSearch}"/>
            <div style="background-color: #FDFFBD;">
            #{itemCTRL.categoryToSearch.descrip}
            </div>
            <br/>
        </h:form>
        <c:choose>
            <c:when test="#{itemCTRL.searchResults != null}">
                <h:form>
                    <h:dataTable width="100%" value="#{itemCTRL.searchResults}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Name"/>
                            </f:facet>
                            <h:outputText value="#{item.name}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Description"/>
                            </f:facet>
                            <h:outputText value="#{item.descrip}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value=" "/>
                            </f:facet>
                            <h:commandLink action="#{itemCTRL.prepareItemView}" value="View"/>
                        </h:column>
                    </h:dataTable>
                </h:form>
            </c:when>
            <c:otherwise>
                No matches found!
            </c:otherwise>
        </c:choose>
        
        
    </ui:define>

</ui:composition>
